package ge.devfest.hackathon.gg.utils;

import ge.devfest.hackathon.gg.R;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.TextView;

public class CheckableTextView extends TextView implements Checkable {

	private boolean mChecked;
	private int mCheckedResId = R.drawable.drawer_item_bg_checked;
	private int mNormalResId = R.drawable.drawer_item_bg_normal;
	
	public CheckableTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void setCheckedResId(int resId) {
		mCheckedResId = resId;
	}
	
	public void setNormalResId(int resId) {
		mNormalResId = resId;
	}
	
	@Override
	public void setChecked(boolean checked) {
		mChecked = checked;
		if (mChecked) {
			setBackgroundResource(mCheckedResId);
		} else {
			setBackgroundResource(mNormalResId);
		}
	}

	@Override
	public boolean isChecked() {
		return mChecked;
	}

	@Override
	public void toggle() {
		setChecked(!mChecked);
	}

}